Memory Leak Problem with XML Native Perms

I am seeing a memory leak problem just looping through XML elements.  I pass a DOM_Element_ into a routine and loop through as follows, using Mathias' memory leak checker as follows:-

void readXMLData(DOM_Element_ xmlEltA)

   DOM_Element_ xmlEltB = null

   memoryCount = LeakCheck()

   for xmlEltB in xmlEltA do

   {

      theLeakThisTime = LeakCheck() - memoryCount

      print theLeakThisTime ", "

}

The output is :-

1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37,

i.e the leakage increments with every step through the loop.  Just to be certain I ran it just checking before and after the loop with no code in the loop - it is definitely just looping through that causes the leak.  Has anyone else seen this?  Does anyone have a way of stopping it?


TheRat - Wed Nov 25 22:45:17 EST 2015

Re: Memory Leak Problem with XML Native Perms
Mathias Mamsch - Thu Nov 26 01:40:10 EST 2015

So either it is the for loop (for xmlEltB in ...) or your LeakCheck code.

Can you move the LeakCheck code out of the loop and see if you get the same result? Or post the LeakCheck() code, to make sure that is not the function that is leaking.

Did you check if there is a destructor for DOM_Element_ ?

Regards, Mathias

Re: Memory Leak Problem with XML Native Perms
TheRat - Thu Nov 26 02:21:14 EST 2015

Hi Mathias, I was hoping you would respond!  Just to be certain I ran it just checking before and after the loop with no code in the loop - it is definitely just looping through that causes the leak.  couldn't find a destructor for DOM_Element_ .  The LeakCheck() code came from you originally so I trust it totally!! I'm looking at swapping to your library XML routines at the moment - just having to work out how to load a buffer from a file into an XMLDocument then extract the root XMLTag from that and lastly the loop through the Child XMLTags.

Re: Memory Leak Problem with XML Native Perms
Mathias Mamsch - Thu Nov 26 11:24:42 EST 2015

TheRat - Thu Nov 26 02:21:14 EST 2015

Hi Mathias, I was hoping you would respond!  Just to be certain I ran it just checking before and after the loop with no code in the loop - it is definitely just looping through that causes the leak.  couldn't find a destructor for DOM_Element_ .  The LeakCheck() code came from you originally so I trust it totally!! I'm looking at swapping to your library XML routines at the moment - just having to work out how to load a buffer from a file into an XMLDocument then extract the root XMLTag from that and lastly the loop through the Child XMLTags.

If this is the case and you need to use these perms, you need to wrap the complete loop inside an eval_ that will make sure, that the allocations are disposed after the loop.

There are other types that show the same behaviour: Stream ,Comment, etc. Regards, Mathias

Re: Memory Leak Problem with XML Native Perms
Wolfgang Uhr - Tue Dec 01 07:58:37 EST 2015

Hi

The snippet

for xmlEltB in xmlEltA do

   {

      theLeakThisTime = LeakCheck() - memoryCount

      print theLeakThisTime ", "

}

is a type of pseudo code. Actually i do not know how to realize such a loop in dxl using own types. So you in the normal case you have routine like "getNextDOM_Element_(xmlEltA)" and this routine creates an ole object which handles the next xml-snippet. I think that in the normal case, this ole object performs this increase. So: Each ole-object you create, you have to delete. So change the code to:

for xmlEltB in xmlEltA do

   {

      theLeakThisTime = LeakCheck() - memoryCount

      print theLeakThisTime ", "

      deleteOleObjectOf(xmlEltB);

}

Best regards

Wolfgang